package pta.test0809.PersonSortable类;

import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int n = cin.nextInt();
        PersonSortable[] stu = new PersonSortable[n];
        for(int i=0;i<n;i++)
        {
            String s = cin.next();
            int j = cin.nextInt();
            stu[i]=new PersonSortable(s,j);
        }
        Arrays.sort(stu);
        for(int i=0;i<n;i++)
        {
            System.out.println(stu[i].toString());
        }
        System.out.println(Arrays.toString(PersonSortable.class.getInterfaces()));
    }
}
class PersonSortable implements Comparable<PersonSortable>{
    private String name;
    private int age;

    public PersonSortable() {
        this.name = name;
        this.age = age;
    }
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
    public PersonSortable(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return name+"-"+age;
    }

    @Override
    public int compareTo(PersonSortable o) {
        if (this.name.compareTo(o.name) > 0) return 1; //若为升序，则返回1(真)
        else if (this.name.compareTo(o.name) < 0) return -1; //反之返回-1
        else {
            if (this.age < o.age) return -1;    //若年龄比比较者小，返回-1(假)
            else return 1;                //反之返回1
        }
    }
}
